<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<tiles:insert definition="Framework.Resource"  flush="true">
<tiles:put name="modno"  value="1" />
<tiles:put name="title">
<bean:message key="framework.resmgr.search"/>
</tiles:put>
<tiles:put name="content">
<base target="_self">
<html:form action="/protected/resmgr/updateUpload.do" method="post" enctype="multipart/form-data">

<html:hidden property="submitButton"/>
<html:hidden property="openedDirectory"/>
<!-- We have to add this,
  -- It seems that struts can't handle the
  -- upload file name correctly
  -- Will be studied latter
  -->
<html:hidden property="uploadFilename" />

<script language="javascript">
    function onok()
    {
        // Show the filename
        document.forms[0].uploadFilename.value = document.forms[0].file.value;
        document.forms[0].submitButton.value = "ok";
    }

    function oncancel()
    {
        document.forms[0].submitButton.value = "cancel";
    }
</script>

<table border="0" cellpadding="0" cellspacing="1" style="border-collapse: collapse" width="748" id="AutoNumber1" align="center" height="500" bgcolor="#CCCCCC">
  <tr>
    <td width="567" bgcolor="#FFFFFF" valign="top">
      <div align="center">
        <table border="0" cellpadding="0" cellspacing="1" style="border-collapse: collapse" width="746" id="AutoNumber1" bgcolor="#f1f1f1" align="center">
          <tr bordercolor="#c0c0c0" bgcolor="#CCCCCC">
            <td align="right" nowrap height="26" colspan="2">
              <div align="left">
              <b><bean:message bundle="resMgr" key="ResMgr.uploadfile"/></b>
              </div>
            </td>
          </tr>

          <tr bordercolor="#c0c0c0" bgcolor="#FFFFFF">
            <td align="right" nowrap height="26">
              <div align="center"></div>
              <div align="center">
              <bean:message bundle="resMgr" key="ResMgr.uploadposition"/>
              </div>
            </td>
            <td>
              &nbsp;<bean:write name="resmgrUploadForm" property="virtualPath"/>
            </td>
          </tr>

          <tr bordercolor="#c0c0c0" bgcolor="#FFFFFF">
            <td align="right" nowrap height="26">
              <div align="center"></div>
              <div align="center">
              <bean:message bundle="resMgr" key="ResMgr.filename"/>
              </div>
            </td>
            <td>
              &nbsp;<html:text property="newFileName"/>
            </td>
          </tr>

          <tr bordercolor="#c0c0c0" bgcolor="#FFFFFF">
            <td bordercolor="#C0C0C0" height="26">
              <div align="center">
                <div align="center"></div>
                <div align="center">
                  <bean:message bundle="resMgr" key="ResMgr.fileposition"/>
                </div>
              </div>
            </td>
            <td height="26">
              &nbsp;<html:file property="file" style="width:300px;" onchange="changeFile(this.form)"/>
            </td>
          </tr>
          <tr bordercolor="#c0c0c0" bgcolor="#f1f1f1">
            <td bordercolor="#C0C0C0" height="26">&nbsp;</td>
            <td height="26">
              <html:submit onclick="onok()">
                  <bean:message bundle="resMgr" key="ResMgr.ok"/>
              </html:submit>
              <html:submit onclick="oncancel()">
                  <bean:message bundle="resMgr" key="ResMgr.cancel"/>
              </html:submit>
            </td>
          </tr>
        </table>
      </div>
    </td>
  </tr>
</table>

</html:form>
</tiles:put>
</tiles:insert>
<script type="">
  function changeFile(fm){
    if(fm.newFileName.value == ""){
      var sName = fm.file.value;
      var sAnd = sName.lastIndexOf("\\")+1;
      sName = sName.substring(sAnd,sName.length);
      fm.newFileName.value=sName;
    }
  }
</script>
